<template>
    <div class="logisticsCompanyDetail">
        <div class="bottom">
            <div style="padding:0">
                <p style="font-size:20px">基础信息</p>
                <el-form ref="baseForm" :model="baseModel" :rules="dictRule" label-width="120px" class="baseForm"
                    label-position="top" size="medium">
                    <el-row :gutter="50">

                        <el-col :span="6">
                            <el-form-item label="车牌号:" prop="vehicleNumber">
                                <el-input v-model.trim="baseModel.vehicleNumber" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="号牌颜色:" prop="vehicleColor">
                                <el-select style="width:100%" v-model="baseModel.vehicleColor" placeholder="请选择" filterable>
                                    <el-option v-for="(item, index) in selectOptions.vehicleColorOptions" :key="index" :value="item.id"
                                        :label="item.dictValue" />
                                </el-select>
                                <!-- <el-input  v-model="baseModel.system" readonly></el-input> -->

                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="排放标准:" prop="emissionStandard">
                                <el-select style="width:100%" v-model="baseModel.emissionStandard" placeholder="请选择"
                                    filterable>
                                    <el-option v-for="(item, index) in selectOptions.emissionStandardOptions" :key="index"
                                        :value="item.id" :label="item.dictValue" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="联网状态:" prop="networkStatus">
                                <el-select style="width:100%" v-model="baseModel.networkStatus" placeholder="请选择"
                                    filterable>
                                    <el-option v-for="(item, index) in networkStatusOptions" :key="index"
                                        :value="item.value" :label="item.label" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <!-- 车型 -->
                        <el-col :span="6">
                            <el-form-item label="车型:" prop="vehicleType">
                                <el-select style="width:100%" v-model="baseModel.vehicleType" placeholder="请选择" filterable>
                                    <el-option v-for="(item, index) in selectOptions.vehicleTypeOptions" :key="index" :value="item.id"
                                        :label="item.dictValue" />
                                </el-select>
                            </el-form-item>
                        </el-col>

                        <el-col :span="6">
                            <el-form-item label="运营证号:" prop="operatingNumber">
                                <el-input v-model.trim="baseModel.operatingNumber" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="所有人电话:" prop="ownerPhone">
                                <el-input v-model.trim="baseModel.ownerPhone" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="是否集装箱:" prop="isContainer">
                                <el-radio-group v-model="baseModel.isContainer">
                                    <el-radio :label="1">是</el-radio>
                                    <el-radio :label="0">否</el-radio>
                                </el-radio-group>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="车辆状态:" prop="vehicleStatus">
                                <el-select style="width:100%" v-model="baseModel.vehicleStatus" placeholder="请选择"
                                    filterable>
                                    <el-option v-for="(item, index) in vehicleStatusOptions" :key="index"
                                        :value="item.value" :label="item.label" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="是否启用:" prop="isActive">

                                <el-switch v-model="baseModel.isActive" />
                                <span class="ml20">关闭后车辆在系统停止使用</span>

                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>

                <div class="picMain">
                    <el-form ref="picModal" :model="picModal" :rules="dictRule" label-width="120px" class="baseForm"
                        label-position="top" size="medium">
                        <el-row>
                            <el-col :span="12" :xl="12" :lg="24" :md="24">
                                <div style="display:flex;align-items: center;">
                                    <p style="font-size:20px">证件照片</p>
                                    <span class="ml20">
                                        支持扩展名：.png .jpg .jpeg .pdf；单个文件大小不超过500MB
                                    </span>

                                </div>
                                <div style="display:flex;">
                                    <div class="tac">
                                        <el-form-item label="行驶证(主页)" prop="licensePhotoMain">
                                            <imageUpload v-model="picModal.licensePhotoMain" :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                    <div class="ml20 tac">
                                        <el-form-item label="行驶证(副页)" prop="licensePhotoCopy">
                                            <imageUpload v-model="picModal.licensePhotoCopy" :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                    <div class="ml20 tac">
                                        <el-form-item label="运营证" prop="operatingLicensePhoto">
                                            <imageUpload v-model="picModal.operatingLicensePhoto" :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                    <div class="ml20 tac">
                                        <el-form-item label="车头" prop="vehiclePhoto">
                                            <imageUpload v-model="picModal.vehiclePhoto" :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                    <div class="ml20 tac">
                                        <el-form-item label="车身铭牌" prop="vehicleVinPlatePhoto">
                                            <imageUpload v-model="picModal.vehicleVinPlatePhoto" :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                </div>
                            </el-col>
                            <el-col :span="12" :xl="12" :lg="24" :md="24">
                                <div style="display:flex;align-items: center;">
                                    <p style="font-size:20px">材料照片</p>
                                    <span class="ml20">
                                        支持扩展名：.png .jpg .jpeg .pdf；单个文件大小不超过500MB
                                    </span>

                                </div>
                                <div style="display:flex;">
                                    <div class="tac">
                                        <el-form-item label="环保清单" prop="envInspectionPhoto">
                                            <imageUpload v-model="picModal.envInspectionPhoto" :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                    <div class="ml20 tac">


                                        <el-form-item label="机动车环保网查询" prop="engineEnvQueryPhoto">
                                            <imageUpload v-model="picModal.engineEnvQueryPhoto" :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                    <div class="ml20 tac">
                                        <el-form-item label="重型柴油车辆排放阶段" prop="heavyDieselVehicleEmissionPhoto">
                                            <imageUpload v-model="picModal.heavyDieselVehicleEmissionPhoto"
                                                :isShowTip="false" />
                                        </el-form-item>

                                    </div>
                                </div>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
                <div style="display:flex;align-items: center;">
                    <p style="font-size:20px">行驶证信息</p>
                    <span class="ml20">
                        上传行驶证照片后自动填写
                    </span>

                </div>
                <el-form ref="drivingLicenseForm" :model="drivingLicenseModel" :rules="dictRule" label-width="120px"
                    class="baseForm" label-position="top" size="medium">
                    <el-row :gutter="50">

                        <el-col :span="6">
                            <el-form-item label="行驶证号:" prop="drivingLicenseNumber">
                                <el-input v-model.trim="drivingLicenseModel.drivingLicenseNumber" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="车辆类型:" prop="drivingVehicleType">
                                <el-select style="width:100%" v-model="drivingLicenseModel.drivingVehicleType"
                                    placeholder="请选择" filterable>
                                    <el-option v-for="(item, index) in selectOptions.drivingVehicleTypeOptions" :key="index"
                                        :value="item.id" :label="item.dictValue" />
                                </el-select>
                                <!-- <el-input  v-model="baseModel.system" readonly></el-input> -->

                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="所有人:" prop="ownerName">
                                <el-input v-model.trim="drivingLicenseModel.ownerName" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="住址:" prop="address">
                                <el-input v-model.trim="drivingLicenseModel.address" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="使用性质:" prop="usageType">
                                <el-select style="width:100%" v-model="drivingLicenseModel.usageType" placeholder="请选择"
                                    filterable>
                                    <el-option v-for="(item, index) in selectOptions.usageTypeOptions" :key="index" :value="item.id"
                                        :label="item.dictValue" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <!-- 车型 -->
                        <el-col :span="6">
                            <el-form-item label="品牌型号:" prop="brand">
                                <el-input v-model.trim="drivingLicenseModel.brand" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>

                        <el-col :span="6">
                            <el-form-item label="车辆识别代号:" prop="vinNumber">
                                <el-input v-model.trim="drivingLicenseModel.vinNumber" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="发动机号:" prop="engineNumber">
                                <el-input v-model.trim="drivingLicenseModel.engineNumber" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="注册日期:" prop="registrationDate">
                                <el-date-picker style="width:100%" v-model="drivingLicenseModel.registrationDate"
                                    type="date" :clearable="false" value-format="yyyy-MM-dd" size="" />
                            </el-form-item>

                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="发证日期:" prop="issueDate">
                                <el-date-picker style="width:100%" v-model="drivingLicenseModel.issueDate" type="date"
                                    :clearable="false" value-format="yyyy-MM-dd" size="" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="核定载质量(kg):" prop="allowedLoadWeight">
                                <el-input v-model.trim="drivingLicenseModel.allowedLoadWeight" placeholder="请输入">
                                </el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item label="燃料类型:" prop="fuelType">

                                <el-select style="width:100%" v-model="drivingLicenseModel.fuelType" placeholder="请选择"
                                    filterable>
                                    <el-option v-for="(item, index) in selectOptions.fuelTypeOptions" :key="index" :value="item.id"
                                        :label="item.dictValue" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>


                </el-form>
                <el-row type="flex" justify="end">
                    <el-col :span="2" :lg="4">
                        <el-button type="">
                            取消
                        </el-button>
                        <el-button type="primary" @click="submit">
                            确定
                        </el-button>
                    </el-col>
                </el-row>
            </div>
        </div>


    </div>
</template>

<script>
import LPTablePage from '@/components/LPTablePage'
import SearchBar from '@/components/SearchBar'
import baseDialog from '@/components/BaseDialog'
import ImagePreview from '@/components/ImagePreview';
import masterDataApi from '@/api/logistics/masterData'
export default {
    name: 'logisticsCompanyDetail',
    components: {
        LPTablePage, SearchBar, baseDialog,
        ImagePreview,
    },
    data() {
        return {
            vehicleVisile: false,
            addVisile: false,
            auditVisile: false,
            auditParams: {

            },
            picModal: {
                licensePhotoMain:null,
                licensePhotoCopy:null,
                operatingLicensePhoto:null,
                vehiclePhoto:null,
                vehicleVinPlatePhoto:null,
                envInspectionPhoto:null,
                engineEnvQueryPhoto:null,
                heavyDieselVehicleEmissionPhoto:null,
            },//图片信息
            drivingLicenseModel: {
                drivingLicenseNumber:'',
                drivingVehicleType:null,
                ownerName:'',
                address:'',
                usageType:null,
                brand:'',
                vinNumber:'',
                engineNumber:'',
                registrationDate:null,
                issueDate:null,
                allowedLoadWeight:null,
                fuelType:null
            },//行驶证信息
            baseModel: {
                vehicleNumber:'',
                isActive: true,
                vehicleColor:null,
                emissionStandard:null,
                networkStatus:null,
                vehicleType:null,
                operatingNumber:'',
                ownerPhone:'',
                isContainer:null,
                vehicleStatus:null,
                
            },//基础信息
            activeName: '0',
            searchModel: {},
            relevanceVehicleSearchModel: {},
            relevanceVehicleData: [],
            auditTableData: [],
            tableData: [],

            imgurl: 'http://43.138.9.96:9000/ruoyi/2024/09/30/2d0d4f03fcbc47988fd60060532b68c4.png',
            total: 0,
            relevanceVehicleTotal: 0,

            currentPage: 1,
            relevanceVehicleCurrentPage: 1,
            vehicleStatusOptions: [
                {
                    label: '可用',
                    value: 1
                },
                {
                    label: '停用',
                    value: 0
                },
            ],
            relevanceVehicleSearchData: [
                {
                    placeholder: "车辆状态", prop: "userName",

                    type: 'select',

                    options: [
                        { label: '成功', value: '0' },
                        { label: '失败', value: '1' },

                    ]
                },
                {
                    placeholder: "车牌号", prop: "aa",



                },
                {
                    prop: 'status',
                    type: 'select',
                    placeholder: '是否启用',
                    options: [
                        { label: '成功', value: '0' },
                        { label: '失败', value: '1' },

                    ]

                },


                {
                    prop: 'search',
                    type: 'button',
                    // policy: ['system.log.query'],
                },
            ],
            networkStatusOptions: [
                {
                    label: '未联网',
                    value: 0
                },
                {
                    label: '已联网',
                    value: 1
                },
            ],
          selectOptions:{
            vehicleColorOptions: [
                {
                    label: '蓝牌',
                    value: '1'
                },
                {
                    label: '黄牌',
                    value: '2'
                }, {
                    label: '白牌',
                    value: '3'
                },
            ],
            emissionStandardOptions: [
                {
                    label: '国零',
                    value: '0'
                },
                {
                    label: '国一',
                    value: '1'
                }, {
                    label: '国二',
                    value: '2'
                },
                {
                    label: '国三',
                    value: '3'
                },
            ],
           
            vehicleTypeOptions: [
                {
                    label: '侧翻车-高箱',
                    value: '0'
                },
                {
                    label: '侧翻车-低箱',
                    value: '1'
                },
            ],
       
            drivingVehicleTypeOptions: [
                {
                    label: '重型半挂牵引车',
                    value: '1'
                },

            ],
            usageTypeOptions: [
                {
                    label: '货运',
                    value: '1'
                },
                {
                    label: '危化品运输',
                    value: '2'
                },
            ],
            fuelTypeOptions: [
                {
                    label: '柴油',
                    value: '1'
                },
                {
                    label: '天然气',
                    value: '2'
                },
            ],
          },


          
            searchData: [
                { placeholder: "操作", prop: "ipaddr", },
                { placeholder: "操作事件", prop: "userName" },
                { placeholder: "操作人", prop: "aa" },
                {
                    label: "操作时间", prop: "loginTime", type: "daterangehms",
                    startPlaceholder: "起始时间",
                    endPlaceholder: "结束时间",

                },
                {
                    prop: 'search',
                    type: 'button',
                    // policy: ['system.log.query'],
                },
            ],
            auditTableColumn: [

                { label: "操作事件", prop: "status", },
                { label: "审核时间", prop: "infoId", },

                { label: "审核人", prop: "userName" },
                { label: "审核结果", prop: "ipaddr", },
                { label: "审核说明", prop: "status", },
            ],
            relevanceVehicleTableColumn: [
                { label: "关联时间", prop: "infoId", },

                { label: "车牌号", prop: "userName" },
                { label: "关系类型", prop: "ipaddr", },
                { label: "排放标准", prop: "ipaddr", },
                { label: "是否启用", prop: "ipaddr", },
                { label: "操作人", prop: "ipaddr", },


            ],
            tableColumn: [

                { label: "操作时间", prop: "infoId", },

                { label: "操作人", prop: "userName" },
                { label: "操作", prop: "ipaddr", },
                { label: "操作事件", prop: "infoId", },

            ],
            dictRule: {
                vehicleNumber: [{ required: true, trigger: "blur", message: "必填" }],
                vehicleColor: [{ required: true, trigger: "change", message: "必选" }],
                emissionStandard: [{ required: true, trigger: "change", message: "必选" }],
                networkStatus: [{ required: true, trigger: "change", message: "必选" }],
                vehicleType: [{ required: true, trigger: "change", message: "必选" }],
                operatingNumber: [{ required: true, trigger: "blur", message: "必填" }],
                ownerPhone: [{ required: true, trigger: "blur", message: "必填" }],
                isContainer: [{ required: true, trigger: "change", message: "必选" }],
                vehicleStatus: [{ required: true, trigger: "change", message: "必选" }],
                isActive: [{ required: true, trigger: "change", message: "必选" }],
                drivingLicenseNumber: [{ required: true, trigger: "blur", message: "必填" }],
                drivingVehicleType: [{ required: true, trigger: "change", message: "必选" }],
                ownerName: [{ required: true, trigger: "blur", message: "必填" }],

                usageType: [{ required: true, trigger: "change", message: "必选" }],

                brand: [{ required: true, trigger: "blur", message: "必填" }],
                vinNumber: [{ required: true, trigger: "blur", message: "必填" }],
                engineNumber: [{ required: true, trigger: "blur", message: "必填" }],

                registrationDate: [{ required: true, trigger: "change", message: "必选" }],

                issueDate: [{ required: true, trigger: "change", message: "必选" }],

                allowedLoadWeight: [{ required: true, trigger: "blur", message: "必填" }],
                fuelType: [{ required: true, trigger: "blur", message: "必填" }],
                // 图片验证：
                licensePhotoMain: [{ required: true, trigger: "change", message: "必选" }],
                licensePhotoCopy: [{ required: true, trigger: "change", message: "必选" }],
                operatingLicensePhoto: [{ required: true, trigger: "change", message: "必选" }],
                vehiclePhoto: [{ required: true, trigger: "change", message: "必选" }],
                vehicleVinPlatePhoto: [{ required: true, trigger: "change", message: "必选" }],
                envInspectionPhoto: [{ required: true, trigger: "change", message: "必选" }],
                engineEnvQueryPhoto: [{ required: true, trigger: "change", message: "必选" }],
                heavyDieselVehicleEmissionPhoto: [{ required: true, trigger: "change", message: "必选" }],


            },
        }
    },
    created(){
        
        this.getQueryDictDetailByCodeWay('vehicleColor')
        this.getQueryDictDetailByCodeWay('emissionStandard')//排放标准
        // this.getQueryDictDetailByCodeWay('networkStatus') //联网状态
        this.getQueryDictDetailByCodeWay('vehicleType')//车型
        this.getQueryDictDetailByCodeWay('drivingVehicleType') //车辆类型
        this.getQueryDictDetailByCodeWay('usageType') //使用性质
        this.getQueryDictDetailByCodeWay('fuelType') //燃料类型
    },
  mounted(){
    this.getDetail();
  },
  watch: {
        'picModal.licensePhotoMain': {
         
            handler(newVal, oldVal) {
                // 判断上传时候调用
                if(newVal&&newVal.length&&newVal[0].name){
                    console.log('====================================');
                    console.log(this.picModal.licensePhotoMain[0].url,'this.picModal.licensePhotoMain[0].url');
                    console.log('====================================');
                    this.getQueryVehicleInfoWay(
                    {fileUrl:this.picModal.licensePhotoMain[0].url,
                    side:'face'
                    })
                }
            },
            deep: true,
            immediate: true
        },
        'picModal.licensePhotoCopy': {
            handler(newVal, oldVal) {
                if(newVal&&newVal.length&&newVal[0].name){
                    this.getQueryVehicleInfoWay(
                    {fileUrl:this.picModal.licensePhotoCopy[0].url,
                    side:'back'
                    }
                    )
                }
            },
            deep: true,
            immediate: true
        },
        
    },
    methods: {
            // 字典值回显操作(value=>id)
       showByDict(dictCode,val){
        let name = `${dictCode}Options`
       let arr = this.selectOptions[name].filter(item=>val==item.dictValue)
        if(arr.length){
            return arr[0].id
        }else{
            return '暂无此字典值'
        }
    },
           // 查询行驶证信息根据上传的行驶证照片
           getQueryVehicleInfoWay(obj) {

 
            masterDataApi.getQueryVehicleInfo(obj).then(res=>{
                if(res.code==200){
               
                  if(obj.side=='face'){
                    this.drivingLicenseModel.address =res.data.address
                    this.drivingLicenseModel.engineNumber =res.data.engineNumber
                    this.drivingLicenseModel.ownerName =res.data.ownerName
                    this.drivingLicenseModel.issueDate =res.data.issueDate
                    this.drivingLicenseModel.vinNumber =res.data.vinNumber
                    this.drivingLicenseModel.registrationDate =res.data.registrationDate
                    this.drivingLicenseModel.brand =res.data.brand
                    this.drivingLicenseModel.usageType =this.showByDict('usageType',res.data.usageType)
                    this.drivingLicenseModel.drivingVehicleType =this.showByDict('drivingVehicleType',res.data.drivingVehicleType)
                    this.drivingLicenseModel.drivingLicenseNumber =res.data.drivingLicenseNumber
                  }else{
                    
                    this.drivingLicenseModel.allowedLoadWeight =res.data.allowedLoadWeight
                    this.drivingLicenseModel.fuelType =this.showByDict('fuelType',res.data.fuelType)
                  }
                   
                }else{

                }
            })
        },
        getDetail() {
            masterDataApi.getVehicleInfoDetail(this.$route.params.id).then((res) => {
                if (res.code == 200) {
                 this.setShow(res.data)
                 this.setDrivingLicenseModelShow(res.data)
                }
            });
        },
        // 回显操作
        setShow(data){
            this.baseModel.vehicleNumber = data.vehicleNumber
            // this.baseModel.vehicleColor = this.showByDict('vehicleColor',data.vehicleColor)
            // this.baseModel.emissionStandard = this.showByDict('emissionStandard',data.emissionStandard)
            // this.baseModel.networkStatus = this.showByDict('networkStatus',data.networkStatus)
            // this.baseModel.vehicleType = this.showByDict('vehicleType',data.vehicleType)
            this.baseModel.vehicleColor = data.vehicleColor
            this.baseModel.emissionStandard = data.emissionStandard
            this.baseModel.networkStatus =data.networkStatus
            this.baseModel.vehicleType =data.vehicleType
            this.baseModel.operatingNumber = data.operatingNumber
            this.baseModel.ownerPhone = data.ownerPhone
            this.baseModel.isContainer = data.isContainer
            this.baseModel.vehicleStatus = data.vehicleStatus
            this.baseModel.isActive = data.isActive== 1 ? true : false
            // 
            this.picModal.licensePhotoMain =  [{
                url:data.licensePhotoMain
            }]
            this.picModal.licensePhotoCopy =  [{
                url:data.licensePhotoCopy
            }]
            this.picModal.operatingLicensePhoto =  [{
                url:data.operatingLicensePhoto
            }]
            this.picModal.vehiclePhoto =  [{
                url:data.vehiclePhoto
            }]
            this.picModal.vehicleVinPlatePhoto =  [{
                url:data.vehicleVinPlatePhoto
            }]
            this.picModal.envInspectionPhoto =  [{
                url:data.envInspectionPhoto
            }]
            this.picModal.engineEnvQueryPhoto =  [{
                url:data.engineEnvQueryPhoto
            }]
            this.picModal.heavyDieselVehicleEmissionPhoto =  [{
                url:data.heavyDieselVehicleEmissionPhoto
            }]
        },
        // 行驶证回显处理
       setDrivingLicenseModelShow(data){
        this.drivingLicenseModel.drivingLicenseNumber = data.drivingLicenseNumber
        this.drivingLicenseModel.drivingVehicleType =  Number(data.drivingVehicleType) //this.showByDict('drivingVehicleType',data.drivingVehicleType)
        this.drivingLicenseModel.ownerName = data.ownerName
        this.drivingLicenseModel.address = data.address
        this.drivingLicenseModel.usageType =  Number(data.usageType)      //this.showByDict('usageType',data.usageType)
        this.drivingLicenseModel.brand = data.brand
        this.drivingLicenseModel.vinNumber = data.vinNumber
        this.drivingLicenseModel.engineNumber = data.engineNumber
        this.drivingLicenseModel.registrationDate = data.registrationDate
        this.drivingLicenseModel.issueDate = data.issueDate
        this.drivingLicenseModel.allowedLoadWeight = data.allowedLoadWeight
        this.drivingLicenseModel.fuelType = Number(data.fuelType) //this.showByDict('fuelType',data.fuelType)
       },
        getQueryDictDetailByCodeWay(dictCode){
            masterDataApi.getQueryDictDetailByCode(dictCode).then(res=>{
                if(res.code==200){
                    let name = `${dictCode}Options`
                    this.$set(this.selectOptions,name,res.data.sysDictDataDetailList)
                    // this.$options.data()
                    // this.[name] = res.data.sysDictDataDetailList
                }
            })
        },
        /*整体提交t操作start*/
        submit() {
            const promises = [];
            promises.push(this.$refs.baseForm.validate());
            promises.push(this.$refs.picModal.validate());
            promises.push(this.$refs.drivingLicenseForm.validate());
            Promise.all(promises).then(() => {
                masterDataApi.updateVehicleInfo(
                    {
                        id:this.$route.params.id,
                        ...this.setParamsWay()
                    }
                ).then(res=>{
                 
                    if(res.code==200){
                        this.$message.warning(res.msg)
                        
                        
                    }else{
                       
                        this.$message.warning('添加失败')
                    }
                })
               
            }).catch(() => {
                console.log('至少有一个表单验证失败');
            })

        },
        resetFormModal(){
            this.baseModel = this.$options.data().baseForm
            this.picModal = this.$options.data().picModal
            this.drivingLicenseModel = this.$options.data().drivingLicenseModel

        },
        setParamsWay() {
         
            let obj = { ...this.baseModel }
            obj.isActive = this.baseModel.isActive == true ? 1 : 0

            let obj1 = {
                ...this.picModal,
                licensePhotoMain: this.picModal.licensePhotoMain[0].url,
                licensePhotoCopy: this.picModal.licensePhotoCopy[0].url,
                operatingLicensePhoto: this.picModal.operatingLicensePhoto[0].url,
                vehiclePhoto: this.picModal.vehiclePhoto[0].url,
                vehicleVinPlatePhoto: this.picModal.vehicleVinPlatePhoto[0].url,
                envInspectionPhoto: this.picModal.envInspectionPhoto[0].url,
                engineEnvQueryPhoto: this.picModal.engineEnvQueryPhoto[0].url,
                heavyDieselVehicleEmissionPhoto: this.picModal.heavyDieselVehicleEmissionPhoto[0].url,

            }
            let obj2 = { ...this.drivingLicenseModel }
            let addParams = {
                ...obj,
                ...obj1,
                ...obj2
            }
          
            return addParams
        },
        /*整体提交t操作end*/


        /*审核操作 start*/
        auditWay() {
            this.auditVisile = true
        },
        handleAuditSubmit() {
            this.$refs.auditParams.validate(valid => {
                if (valid) {
                    console.log('handleAddSubmit 验证通过', this.auditParams);
                    return
                    addDict(this.baseModel).then(res => {
                        if (!res.error) {


                            this.$message.success("审核成功")
                            this.auditVisile = false;

                        }
                    })
                } else {
                    this.$message.warning("审核失败")
                    return false
                }
            })

        },
        handleAuditCancle() {
            this.auditParams = this.$options.data().auditParams
            this.resetForm("auditParams")
            this.auditVisile = false;
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
        /*审核操作 end*/

        /*关联车辆 start*/
        setVehicle() {
            this.vehicleVisile = true
        },
        /*关联车辆  end*/



        /*编辑车辆  start*/
        update() {
            this.addVisile = true
        },
        handleAddSubmit() {
            this.$refs.baseForm.validate(valid => {
                if (valid) {
                    console.log('handleAddSubmit 验证通过', this.baseModel);
                    editDict(this.baseModel).then(res => {
                        if (!res.error) {
                            console.log('editDict', res);

                            this.$message.success("编辑成功")
                            this.handleAddCancle()
                            // 重新查询
                            this.getDictList()
                        }
                    })
                } else {

                    return false
                }
            })
        },
        handleAddCancle() {

            this.baseModel = this.$options.data().baseModel
            this.resetForm("baseForm")
            this.addVisile = false;
        },
        /*编辑车辆 end*/

        //   删除车辆
        edit() {
            this.$confirm('确定删除吗', '取消', {
                cancelButtonText: '取消',
                confirmButtonText: '确定',
                closeOnClickModal: false
            }).then(() => {
                //   console.log('确认');
                deleteFollow({ id: row.id }).then(res => {
                    if (!res.error) {
                        this.$message.success("删除成功")
                        this.getFollowList()
                    }
                })
            })
        },
        // 查询关联车辆表格信息

        getRelevanceVehicleTableList() {
            let { pageSize } = this.$refs.relevanceVehicleTablePage;
        },
        // 查询表格信息
        getTableList() {
            let { pageSize } = this.$refs.tablePage;
        },
        tabHandleClick(tab, event) {
            console.log(tab, event);
        },
        relevanceVehicleHandleCurrentChange(v) {
            this.relevanceVehicleCurrentPage = v;
            this.getRelevanceVehicleTableList()
        },
        relevanceVehicleHandleSizeChange(v) {
            this.pageSize = v;
            this.relevanceVehicleCurrentPage = 1;
            this.getRelevanceVehicleTableList()
        },
        handleCurrentChange(v) {
            this.currentPage = v;
            this.getTableList()
        },
        handleSizeChange(v) {
            this.pageSize = v;
            this.currentPage = 1;
            this.getTableList()
        },
        handleSearchSubmit() {
            this.currentPage = 1;
            this.getTableList()
        },
        handleSearchReset() {
            this.currentPage = 1;
            this.$refs.tablePage.clearSelection()
            this.getTableList()
        },
    }
}
</script>

<style lang="scss" scoped>
.logisticsCompanyDetail {
    padding: 30px;

    .top {
        width: 100%;
        display: flex;
        justify-content: space-between;

        .top_l {
            display: flex;

            .userinfo {
                display: flex;
                flex-direction: column;
                justify-content: space-around;
            }
        }
    }
}

.company {
    width: 0.5rem;
    height: 0.5rem;
    background-color: #0076ff;
    font-size: 20px;
    color: #fff;
    text-align: center;
    line-height: 0.5rem;
    margin-right: 16px;

    .logo {
        width: 51px;
        height: 51px;
    }
}
</style>